<!--类名对应对战模式，换背景图-->
<volist name="data.list" id="room">
    <a onclick="putRing(this)" data-password="{$room.password}" data-is_need_password="{$room.is_need_password}" data-id="{$room.id}">
        <div class="ring-list ring-{$room.model_name}">

            <notempty name="room.password">
                <img src="__PUBLIC__/assets/i/lock.png" width="34" style="position: absolute;top:0;right: 0;" alt="">
            </notempty>
            <div class="am-g">
                <div class="am-u-sm-12">
                    <span>擂台号:{$room.id}</span>
                </div>
                <div class="am-u-sm-offset-1 am-u-sm-10 am-u-end">
                    <span class="oath">擂台宣言：{$room.declaration}</span>
                </div>
                <div class="am-u-sm-4 am-text-center">
                    <!--用户头像 -->
                    <img src="{$room.head_url}" width="70" height="70" class="am-round" alt=""><br>
                    <eq name="room.user_sex" value="0">
                        <img src="__PUBLIC__/assets/i/boy.png" width="20" alt="">
                        <else/><img src="__PUBLIC__/assets/i/girl.png" width="20" alt="">
                    </eq>
                    <span class="username">{$room.user_nickname}</span>
                    <span class="username">{$room.region_name}</span>
                </div>
                <div class="am-u-sm-4 am-padding-0 am-text-center ring-list-detail">
                    <img src="__PUBLIC__/assets/i/vs.png" width="60" alt="">
                    <span>{$room.model_show_name}</span>
                    <span>
                        <eq name="room.money_type" value="1">
                            <img src="__PUBLIC__/assets/i/diamond.png"
                                 style="display: inline-block;margin-top: -3px" width="14" alt="">
                            <else/><img src="__PUBLIC__/assets/i/coin.png"
                                 style="display: inline-block;margin-top: -3px" width="14" alt="">
                        </eq> {$room.integral}</span>
                    <span>
                            <switch name="room.systems_name">
                                <case value="0"><img src="__PUBLIC__/assets/i/add/az.png" width="12" alt=""><span style="vertical-align: middle;display: inline-block">安卓</span></case>
                                <case value="1"><img src="__PUBLIC__/assets/i/add/pg.png" width="12" alt=""><span style="vertical-align: middle;display: inline-block">苹果</span></case>
                            </switch>
                            <switch name="room.region">
                                <case value="0"><img src="__PUBLIC__/assets/i/add/qq.png" width="12" alt=""><span style="vertical-align: middle;display: inline-block">QQ区</span></case>
                                <case value="1"><img src="__PUBLIC__/assets/i/add/wx.png" width="12" alt=""><span style="vertical-align: middle;display: inline-block">微信区</span></case>
                            </switch>
                        </span>
                    <span>
                            <switch name="room.status">
                                <case value="0">等待打擂中...</case>
                                <case value="1">正在打擂中...</case>
                                <case value="2">已经结束</case>
                                <case value="3">已经解散</case>
                            </switch>
                        </span>
                    <!--<span>{$room.create_time}</span>-->
                </div>
                <notempty name="room.opponent_id">
                    <div class="am-u-sm-4 am-text-center">
                        <!--用户头像 -->
                        <img src="{$room.o_head_url}" width="70" height="70" class="am-round" alt=""><br>
                        <eq name="room.opponent_sex" value="0">
                            <img src="__PUBLIC__/assets/i/boy.png" width="20" alt="">
                            <else/><img src="__PUBLIC__/assets/i/girl.png" width="20" alt="">
                        </eq>
                        <span class="username">{$room.opponent_nickname}</span>
                        <span class="username">{$room.o_region_name}</span>
                    </div>
                    <else/>
                    <!--等待用户加入-->
                    <div class="am-u-sm-4 am-text-center">
                        <img src="__PUBLIC__/assets/i/wait.png" width="70" height="70" class="am-round" alt=""><br>
                    </div>
                </notempty>
            </div>
        </div>
    </a>
</volist>
<input type="hidden" id="totalpage" value="{$data.page.totalpage}">
<script>
    function putRing(input) {
        var password = $(input).data('password');
        var is_need_password = $(input).data('is_need_password');
        var id = $(input).data('id');
        console.info(is_need_password);
        var success = false;
        $.ajax({
            type: "POST",
            url: "__APP__/Home/Room/checkRoom",
            async: false,
            data: {
                room_id: id
            },
            dataType: "json",
            success: function (data) {
                success = data.success;
                if(!data.success){
                    if(data.type != 1) {
                        layer.msg(data.message);
                    }else{
                        layer.confirm('对不起，您尚未完善段位信息无法进入，请先完善！', {
                            btn: ['立即前往','稍后再说'] //按钮
                        }, function(){
                            window.location.href = '__APP__/Home/Index/settings';
                        }, function(){

                        });
                    }
                }
            },
            error: function (data) {
                layer.msg('服务器繁忙！');
            }
        });
        if(!success){
            return;
        }
        if(password != '' && is_need_password){
            layer.prompt({title: '请输入房间密码', formType: 1}, function (pass, index) {
                $.ajax({
                    type: "POST",
                    url: "__APP__/Home/Room/checkPassWord",
                    async: false,
                    data: {
                        room_id: id,
                        password:pass
                    },
                    dataType: "json",
                    success: function (data) {
                        console.info(data);
                        layer.msg(data.message);
                        if(data.success){
                            window.location.href = '__APP__/Home/Room/detail?room_id='+id+'&password='+pass;
                        }
                    },
                    error: function (data) {
                        layer.msg('服务器繁忙！');
                    }
                });
            });
        }else{
            window.location.href = '__APP__/Home/Room/detail?room_id='+id;
        }
    }
</script>